
#include "PointAttractorModifier.h"
#include "../../Utils/Timer.h"


PointAttractorModifier::PointAttractorModifier(Vector2D position, float strength) :
    position(position), strength(strength) {

}


PointAttractorModifier::~PointAttractorModifier(){

}


void PointAttractorModifier::modifyParticle(Particle &particle){
    Vector2D vec = position - particle.position;
    float dist = vec.length();
    float pull_strength = strength/dist;
    
    vec.normalise();
    particle.velocity = particle.velocity + pull_strength*Timer::secondsSinceLastFrame()*vec;
}


void PointAttractorModifier::setPosition(Vector2D new_position){
    position = new_position;
}


void PointAttractorModifier::setStrength(float new_strength){
    strength = new_strength;
}

